//
//  SuggestController.m
//  万物记
//
//  Created by Ajen on 2019/6/23.
//  Copyright © 2019 Ajen. All rights reserved.
//

#import "SuggestController.h"
#import <MessageUI/MFMailComposeViewController.h>
@interface SuggestController ()<MFMailComposeViewControllerDelegate>

@end

@implementation SuggestController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    UILabel * titleLabel = [UILabel new];
    titleLabel.aj_Text(@"意见或建议").aj_textColorHexStr(@"#2d2e36").aj_addToView(self.view);
    titleLabel.font = SongKeFont(23);
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.top.equalTo(self.view).offset(STATUS_BAR_HEIGHT);
        make.height.equalTo(@44);
    }];
    self.navigationItem.titleView = titleLabel;
}
- (IBAction)sendEmail:(id)sender {
    MFMailComposeViewController *mailSender = [[MFMailComposeViewController alloc]init];
    mailSender.mailComposeDelegate = self;
    [mailSender setSubject:@"《万物记》意见或建议"];
    [mailSender setMessageBody:@"《万物记》意见或建议" isHTML:NO];
    [mailSender setToRecipients:[NSArray arrayWithObjects:@"heyajen@sina.com", nil]];
    
    [self presentViewController:mailSender animated:YES completion:^{
        
    }];
    
}
- (void)mailComposeController:(MFMailComposeViewController *)controller
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError *)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled: // 用户取消编辑
            NSLog(@"Mail send canceled...");
            break;
        case MFMailComposeResultSaved: // 用户保存邮件
            NSLog(@"Mail saved...");
            break;
        case MFMailComposeResultSent: // 用户点击发送
            NSLog(@"Mail sent...");
            break;
        case MFMailComposeResultFailed: // 用户尝试保存或发送邮件失败
            NSLog(@"Mail send errored: %@...", [error localizedDescription]);
            break;
    }
    
    // 关闭邮件发送视图
    [self dismissViewControllerAnimated:YES completion:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
